package net;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 * 客户端
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket();
        //2秒连接超时
        socket.connect(new InetSocketAddress("127.0.0.1", 8080), 2000);

      /*  PrintStream ps = new PrintStream(socket.getOutputStream());
        ps.print("我是客户端消息");
        ps.flush();*/

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        System.out.println("接收到服务端:" + br.readLine());

        br.close();
        socket.close();
    }
}
